package com.zc.designmodel.behavioral.iterator;


/**
 * @author: zhuCan
 * @date: 2020/4/15 16:53
 * @description:
 */
public class NameRepository implements Container {

  public String[] names = {"Robert", "John", "Julie", "Lora"};


  @Override
  public Iterator iterator() {
    return new NameIterator();
  }

  private class NameIterator implements Iterator {

    private int index;

    @Override
    public boolean hasNext() {
      return index < names.length;
    }

    @Override
    public Object next() {
      return names[index++];
    }
  }
}
